package day15.pool;

import day14.Myrunable;

import java.util.concurrent.*;

public class pollTest {
    public static void main(String[] args) {
//        ExecutorService executorService = Executors.newFixedThreadPool(10);
//        ThreadPoolExecutor pool = (ThreadPoolExecutor) executorService;
//        System.out.println(pool.getPoolSize());
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                2,//核心线程数量
                5,//最大线程数量
                2,//空闲线程最大存活时间
                TimeUnit.MINUTES,//存活时间的单位
                new ArrayBlockingQueue<>(10),//可以执行任务的队列长度
                Executors.defaultThreadFactory(),//创建线程工厂
                new ThreadPoolExecutor.AbortPolicy());//任务的拒绝策略
        pool.submit(new Myrunable());
        pool.submit(new Myrunable());
        pool.shutdown();
    }
}
